const Chapter = require('./chapter.model')
const Course = require('./courses.model')
const Video = require('./video.model')

//建立表关联
Course.hasOne(Chapter, {
  foreignKey: 'course_id',
  as: 'chapterDetail'
})

//Chapter.belongsTo(Course)

Chapter.hasMany(Video, {
  foreignKey: 'chapter_id',
  sourceKey: 'id',
  as: 'lessonInfo'
})

Video.belongsTo(Chapter, {
  foreignKey: 'chapter_id',
  targetKey: 'id'
})
